package com.ruoyi.medical.controller.outpatient;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.medical.domain.outpatient.CostPersonArchives;
import com.ruoyi.medical.service.outpatient.ICostPersonArchivesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 个人档案Controller
 * 
 * @author hyx
 * @date 2023-08-23
 */
@RestController
@RequestMapping("/medical/outpatient/personArchives")
public class CostPersonArchivesController extends BaseController
{
    @Autowired
    private ICostPersonArchivesService costPersonArchivesService;

    /**
     * 查询个人档案列表
     */
    @PreAuthorize("@ss.hasPermi('medical:personArchives:list')")
    @GetMapping("/list")
    public TableDataInfo list(CostPersonArchives costPersonArchives)
    {
        startPage();
        List<CostPersonArchives> list = costPersonArchivesService.selectCostPersonArchivesList(costPersonArchives);
        return getDataTable(list);
    }

    /**
     * 导出个人档案列表
     */
    @PreAuthorize("@ss.hasPermi('medical:personArchives:export')")
    @Log(title = "个人档案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CostPersonArchives costPersonArchives)
    {
        List<CostPersonArchives> list = costPersonArchivesService.selectCostPersonArchivesList(costPersonArchives);
        ExcelUtil<CostPersonArchives> util = new ExcelUtil<CostPersonArchives>(CostPersonArchives.class);
        util.exportExcel(response, list, "个人档案数据");
    }

    /**
     * 获取个人档案详细信息
     */
    @PreAuthorize("@ss.hasPermi('medical:personArchives:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(costPersonArchivesService.selectCostPersonArchivesById(id));
    }

    /**
     * 新增个人档案
     */
    @PreAuthorize("@ss.hasPermi('medical:personArchives:add')")
    @Log(title = "个人档案", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CostPersonArchives costPersonArchives)
    {
        return toAjax(costPersonArchivesService.insertCostPersonArchives(costPersonArchives));
    }

    /**
     * 修改个人档案
     */
    @PreAuthorize("@ss.hasPermi('medical:personArchives:edit')")
    @Log(title = "个人档案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CostPersonArchives costPersonArchives)
    {
        return toAjax(costPersonArchivesService.updateCostPersonArchives(costPersonArchives));
    }

    /**
     * 删除个人档案
     */
    @PreAuthorize("@ss.hasPermi('medical:personArchives:remove')")
    @Log(title = "个人档案", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(costPersonArchivesService.deleteCostPersonArchivesByIds(ids));
    }
}
